package com.link510.aitools.core.data.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/*
简单分页模型
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageModel implements Serializable {

    private static final long serialVersionUID = -7754380404891181365L;
    /**
     * 每页条数
     */
    private int pageSize = 10;

    /**
     * 当前页数
     */
    private int pageNumber = 1;


    /**
     * 总页数
     */
    private int totalPages = 0;

    /**
     * 总条数
     */
    private long totalCount = 0;


    public PageModel(int pageSize, int pageNumber, long totalElements) {

        try {

            if (pageSize > 0) {
                this.pageSize = pageSize;
            }

            if (pageNumber > 0) {
                this.pageNumber = pageNumber;
            }

            this.totalCount = totalElements;

            this.totalPages = (int) ((totalElements + this.pageSize - 1) / this.pageSize);

        } catch (Exception ignored) {

        }

    }





}
